package org.nepu.scr.indexrate.converter.drillingrate.emergencycapability;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.emergencycapability.EmergencyResponse;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class EmergencyResponseConverter implements AttributeConverter<EmergencyResponse, String> {
    @Override
    public String convertToDatabaseColumn(EmergencyResponse emergencyResponse) {
        return JSONUtil.toJsonStr(emergencyResponse);
    }

    @Override
    public EmergencyResponse convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, EmergencyResponse.class);
    }
}
